<?php include load_template('_subnav.php') ?>

<h1>Modify Form</h1>


<?php echo  error_messages_for('inbox') ?>
<?php

    if ( empty($form) )
    {
?>
<div id="tabPanel1" class='tab-pane'>    
        <div id="tabPage1" class='tab-page'>
        <h2 class='tab'>Form Details</h2>      
        <?php echo form_tag('modify',array('validation'=>true))?>
        
        <?php include load_template('_form.php') ?>
        
        <br><?php echo submit_tag('Add Form')?>
        <?php echo end_form_tag()?>
    </div>
</div>
<?php } else { ?>
    <h2>Managing Form: <span style='color:red'><?php echo  $form['form_name'] ?></span></h2>
<div id="tabPanel1" class='tab-pane'>    
        <div id="tabPage1" class='tab-page'>
        <h2 class='tab'>Form Details</h2>      
        <?php echo form_tag('modify',array('validation'=>true))?>
        <?php echo  hidden_field('inbox','id') ?>
        <?php include load_template('_form.php') ?>
        
        <br><?php echo submit_tag('Edit Form')?>
        <?php echo end_form_tag()?>
        </div>
    
    <div id="tabPage2" class='tab-page'>
        <h2 class='tab'>Auto Responder</h2>
        <?php echo form_remote_tag(array('controller'=>'admin/inbox' ,'action'=>'modify_responder'),
                array(
                    'update'=>'success_messages',
                    'complete'=>'toggle_success()',
                    'scripts'=>true
                    )
                )
         ?>
         <?php echo  hidden_field('inbox','id') ?>
         <p>If you would like for an autoresponder to be sent out, create one below.<br>
         You can access non-array form variables as {$form_element_name}</p>
         <label for='inbox_autoresponder_subject'>Autoresponder Subject</label>
         <?php echo  text_field('inbox','autoresponder_subject',array('size'=>'50')) ?>
         
        <label for='inbox_autoresponder'>Autoresponder [text only, no html]</label>
        <?php echo  text_area('inbox','autoresponder',array('size'=>'50x15')) ?>
        <label for='inbox_use_autoresponder'><?php echo  check_box('inbox','disable_autoresponder') ?> disable autoresponder for this form?</label><br/>
        <p><?php echo  submit_tag('Submit') ?></p>
        <?php echo  end_form_tag() ?>
    </div>
    
    <div id="tabPage3" class='tab-page'>
        <h2 class='tab'>Plugins</h2>
        <div class='user_roles' style='width:350px;'>
        <?php echo form_remote_tag(array('controller'=>'admin/inbox' ,'action'=>'modify_plugins'),
                    array(
                            'name'=>'modify_inbox_plugins',
                            'update'=>'success_messages',
                            'before'=>"selectAll('plugins[]')",
                            'complete'=>"toggle_success();",
                        )
                    )
         ?>
        <?php echo hidden_field_tag('id', $form['id'])?>
        <?php echo select_transfer('plugins[]', array_diff( $all_plugins, $plugins), $plugins)?>  
        <p><?php echo submit_tag('Modify Plugins')?></p>
        <?php echo end_form_tag()?>
       </div>
        
    </div>
</div>

<?php } ?>

<script type="text/javascript">
    setupAllTabs();
</script>